package com.yuke.cloud.service.wmc.service.impl;

import com.yuke.cloud.service.api.wmc.dto.WarehouseInfoDto;
import com.yuke.cloud.service.wmc.dao.WmsWarehouseMapper;
import com.yuke.cloud.service.wmc.dto.WmsWarehouseDto;
import com.yuke.cloud.service.wmc.entity.WmsWarehouse;
import com.yuke.cloud.service.wmc.service.WmsWarehouseService;
import com.yuke.cloud.common.core.support.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * Created by zys on 2018/10/22.
 */
@Service
@Transactional
public class WmsWarehouseServiceImpl extends BaseService<WmsWarehouse> implements WmsWarehouseService {
    @Resource
    private WmsWarehouseMapper wmsWarehouseMapper;

    @Override
    public void bookgoods(Long wareshouseid, Long productid, Integer number) {
        wmsWarehouseMapper.bookgoods(wareshouseid, productid, number);
    }

    @Override
    public List<Map> finditall1() {
        return wmsWarehouseMapper.finditall1();
    }

    @Override
    public List<Map> finditall12() {
        return wmsWarehouseMapper.finditall12();
    }

    @Override
    public void beathdelete(List<Long> ids) {
        wmsWarehouseMapper.beathdelete(ids);
    }

    @Override
    public List<Map> findaddress(List<WmsWarehouse> wmsWarehouses) {
        return wmsWarehouseMapper.findaddress(wmsWarehouses);
    }

    @Override
    public List<Map> warehouseifnull(List<Long> ids) {
        return wmsWarehouseMapper.warehouseifnull(ids);
    }

    @Override
    public List<Map> findByPostion(Double latitude, Double longitude, Long maxDistance) {
        return wmsWarehouseMapper.findByPostion(latitude, longitude, maxDistance);
    }

    @Override
    public Map getaddressbyregionid(Long regionId) {
        return wmsWarehouseMapper.getaddressbyregionid(regionId);
    }

    @Override
    public Map getwarehouseaddressbyshopid(String shopId) {

        return wmsWarehouseMapper.getwarehouseaddressbyshopid(Long.valueOf(shopId));
    }

    @Override
    public List<WmsWarehouse> finfbyids(String s) {
        String[] split = s.split(",");
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < split.length; i++) {
            if (split[i] != null && !split[i].equals("")) {
                list.add(Long.valueOf(split[i]));
            }

        }
        return wmsWarehouseMapper.finfbyids(list);
    }

    @Override
    public void updatestorage(WmsWarehouse list1) {
        wmsWarehouseMapper.updatestorage(list1);
    }

    @Override
    public List<Map> findtransferspec(Long specId) {
        return wmsWarehouseMapper.findtransferspec(specId);
    }

    @Override
    public void updateFactoryStorage(Long specId, Integer number) {
        wmsWarehouseMapper.updateFactoryStorage(specId, number);
    }

    @Override
    public Map getWarehouseAddress(Long warehouseId) {
        return wmsWarehouseMapper.getWarehouseAddress(warehouseId);
    }

    @Override
    public List<WarehouseInfoDto> getWarehouseInfo(List<Long> warehouseIds) {
        return wmsWarehouseMapper.getWarehouseInfo(warehouseIds);
    }

    @Override
    public List<WmsWarehouseDto> getWarehouseInfoList(WmsWarehouse warehouse) {
        return wmsWarehouseMapper.getWarehouseInfoList(warehouse);
    }
}
